//
//  ZQNavigationBar.swift
//  Timor微博
//
//  Created by 周周旗 on 2019/2/27.
//  Copyright © 2019 ZQ. All rights reserved.
//

import UIKit

class ZQNavigationBar: UINavigationBar {
    // tabBarHeight
    static  var NaviBarStatusBarHeight : CGFloat{
        // iphone X
        let isIphoneX = UIScreen.main.bounds.size.height >= 812 ? true : false
        return isIphoneX ? 49 + 34 : 49
    }
    // navigationBarHeight
    var navigationBarHeight : CGFloat {
        let isIphoneX = UIScreen.main.bounds.size.height >= 812 ? true : false

        return isIphoneX ? 34:20
    }

    
    /// 重写父类已有的方法，使用继承。而不是扩展
    override func layoutSubviews() {
        super.layoutSubviews()
        
        for subview in self.subviews {
            let stringFromClass = NSStringFromClass(subview.classForCoder)
            print("--------- \(stringFromClass)")
            if stringFromClass.contains("BarBackground") {
                subview.frame = self.bounds
            } else if stringFromClass.contains("UINavigationBarContentView") {
                subview.frame = CGRect(x: 0, y: navigationBarHeight, width: UIScreen.cz_screenWidth(), height: ZQNavigationBar.NaviBarStatusBarHeight)
            }
        }
    }
}
